package com.talkyun.ocean.model;


public class Endpoint {
    private String protocol;
    private String host;
    private int port;
    private String uri;

    private int weight;

    public Endpoint() {
        this.weight = 1;
    }

    public Endpoint(String protocol, String host, int port, String uri) {
        this();
        this.protocol = protocol;
        this.host = host;
        this.port = port;
        this.uri = uri;
    }

    public String toUrl() {
        return protocol + "://" + host + (port == 80 ? "" : ":" + port) + uri;
    }

    @Override
    public String toString() {
        return toUrl();
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }
}